<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/notice' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>最新公告</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card shadow="never">
      <!-- 发布时间 -->
      <span class="time">{{dayjs(news.time).format('YYYY-MM-DD HH:mm')}}</span>
      <!-- 发布内容 -->
      <div v-html="news.inform" class="inform"></div>
      <!-- 发布人 -->
      <span class="author">来自：{{news.author}}</span>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      news: ''
    }
  },
  methods: {
    async getInform() {
      // 发起请求
      let res = await this.$http.get('informs')
      // 获取失败
      if (res.meta.status !== 200) {
        return this.$message.error('获取公告失败')
      }
      // 获取成功
      this.news = res.data
    }
  },
  created() {
    this.getInform()
  }
}
</script>

<style lang="less">
.el-card {
  .time {
    font-size: 12px;
    color: #999;
  }
  .author {
    font-size: 12px;
    color: #406599;
  }
  // padding-bottom: 150px;
  .inform {
    h1 {
      text-align: center;
    }
    p {
      margin: 20px 0;
      // text-indent: 5%;
      line-height: 25px;
    }
  }
}
</style>